# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-phply
pkgname=('python2-phply' 'python-phply')
_pkgname=phply
pkgver=1.2.6
_pyver=3.13
pkgrel=6
pkgdesc='PHP parser written in Python using PLY.'
arch=('any')
url='https://pypi.org/project/phply/#files'
license=('BSD')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('658e48d67b634185bb20637ed92b0e0ce83adaf62a584bcd9caae377bcdd904193398ca7b3947cbfd8998ae10b53ffc0dcf60401a558ab12c6c1b2024c50f284')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"
}

package_python2-phply() {
  depends=('python2' 'python2-ply')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build

  mv "$pkgdir/usr/bin/phplex" "$pkgdir/usr/bin/phplex2"
  mv "$pkgdir/usr/bin/phpparse" "$pkgdir/usr/bin/phpparse2"

  rm -rf "$pkgdir/usr/lib/python2.7/site-packages/tests"
}

package_python-phply() {
  depends=('python' 'python-ply')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build

  rm -rf "$pkgdir/usr/lib/python$_pyver/site-packages/tests"
}

